<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.model.*" %>  
<%@ page import="com.control.*" %>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String course_name=request.getParameter("name");
int teacher_id=Integer.parseInt(request.getParameter("teacher_id"));



Course course=new Course();
CourseControl cc=new CourseControl();
UserControl uc=new UserControl();
if(uc.search_teacher(teacher_id))
{
	course.setName(course_name);
	course.setTeacher_id(teacher_id);
	if(cc.insertCourse(course))
	{
		%>
		<script>
		if(window.confirm("添加成功，是否继续添加课程？"))
			window.location.href="course_insert.jsp";
		</script>
		<%}
	else{ %>
		<script>
		alert("添加失败！");
		window.location.href="course_insert.jsp";//添加链接
		</script>
	<%}
} 
else {%>
	<script>
	alert("教师编号不存在，请重新输入！");
	window.location.href="course_insert.jsp";
	</script>
<% }
%>

	







</body>
</html>